import { pubRequire } from '@utils/public'
const baseUrl = '/dictionaries'
//获取列表
export function getDictionariesList(obj, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/categories`, obj, callbBack, errBack)
}
//批量删除
export function multipleDel(obj, callBack, errBack) {
  return pubRequire('delete', `${baseUrl}/categories`, obj, callBack, errBack)
}
//单个删除
export function singleDel(id, callBack, errBack) {
  return pubRequire(
    'delete',
    `${baseUrl}/categories/${id}`,
    '',
    callBack,
    errBack
  )
}
//导出
export function exportUrl() {
  return `${baseUrl}/categories/export`
}
//字典类型是否重复
export function repeatDictionType(type, obj, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/verifications?type=${type}`,
    obj,
    callBack,
    errBack
  )
}
//获取字典详情
export function getDictionaryDetail(dictId, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/categories/${dictId}`,
    '',
    callBack,
    errBack
  )
}
//编辑字典
export function editDictionary(dictId, obj, callBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/categories/${dictId}`,
    obj,
    callBack,
    errBack
  )
}
//新增字典
export function addDictionary(obj, callBack, errBack) {
  return pubRequire('post', `${baseUrl}/categories`, obj, callBack, errBack)
}
//清除缓存
export function cacheRemove(callBack, errBack) {
  return pubRequire('delete', `${baseUrl}/cache/remove`, '', callBack, errBack)
}
//二级页面-获取列表
export function getDSecondList(obj, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}`, obj, callbBack, errBack)
}
//二级页面-批量删除
export function multipleDelSecond(dictType, obj, callBack, errBack) {
  return pubRequire(
    'delete',
    `${baseUrl}?type=${dictType}`,
    obj,
    callBack,
    errBack
  )
}
//二级页面-单个删除
export function singleDelSecond(dictType, id, callBack, errBack) {
  return pubRequire(
    'delete',
    `${baseUrl}/${id}/categories?type=${dictType}`,
    '',
    callBack,
    errBack
  )
}
//二级页面-导出
export function exportSecondUrl(dictType) {
  return `${baseUrl}/export?type=${dictType}`
}
//二级页面-获取字典详情
export function getDSecondDetail(dictType, dictCode, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/${dictCode}/categories?type=${dictType}`,
    '',
    callBack,
    errBack
  )
}
//二级页面-编辑字典
export function editDSecond(dictType, dictCode, obj, callBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/${dictCode}/categories?type=${dictType}`,
    obj,
    callBack,
    errBack
  )
}
//二级页面-新增字典
export function addDSecond(dictType, obj, callBack, errBack) {
  return pubRequire(
    'post',
    `${baseUrl}?type=${dictType}`,
    obj,
    callBack,
    errBack
  )
}
//二级页面-获取字典名称
export function getDictionaryName(callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/categories/options`,
    '',
    callBack,
    errBack
  )
}
